package cn.mdx.controller;

import cn.mdx.common.beans.ResultBean;
import cn.mdx.common.beans.User;
import cn.mdx.pojo.Demand;
import cn.mdx.pojo.Needuser;
import cn.mdx.pojo.Result;
import cn.mdx.service.DemandService;
import cn.mdx.service.ResourceService;
import cn.mdx.service.VoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@SuppressWarnings({"ALL", "AlibabaClassMustHaveAuthor"})
@RestController
@Controller
@RequestMapping("/need")
@CrossOrigin
public class NeedController {

    @Autowired
    private DemandService demandService;

    @Autowired
    private ResourceService resourceService;


    @Autowired
    private VoService voService;

    @PostMapping("/addDemand")
    public ResultBean addDemand(Demand demand, HttpSession session) {
        demandService.addDemand(demand,User.getId(session));
        return new ResultBean();
    }

    @PostMapping("/setDemand")
    public ResultBean setDemand(Demand demand,HttpSession session) {
        demandService.setDemand(demand,User.getId(session));
        return new ResultBean();
    }

    @RequestMapping("/getDemandsId")
    public ResultBean getDemandsId(HttpSession session) {
        return new ResultBean(demandService.getDemandsId(User.getId(session)));
    }


    @PostMapping("/delDemand")
    public ResultBean delDemand(Integer id,HttpSession session) {
        demandService.delDemand(id,User.getId(session));
        return new ResultBean();
    }

    @PostMapping("/getDemand")
    public ResultBean getDemand(Integer id,HttpSession session) {
        return new ResultBean(demandService.getDemand(id,User.getId(session)));
    }

    @RequestMapping("/getDemandList")
    public ResultBean getDemandList(HttpSession session) {
        return new ResultBean(voService.getDemandList(User.getId(session)));
    }

    @PostMapping("/getUserInfo")
    public ResultBean getUserInfo(Integer id) {
        return  new ResultBean(voService.selectSkillUserById(id));
    }

    @RequestMapping("/getSkillUser")
    public ResultBean getSkillUser(Integer page,String info){
        return new ResultBean(voService.getSkillList(page,info));
    }

    @RequestMapping("/findService")
    public ResultBean findService(Integer page,String info){
        return new ResultBean(voService.findServiceList(page,info));
    }


    @PostMapping("/getPatent")
    public ResultBean getPatent(Integer id)  {
        return new ResultBean(resourceService.getAuditPatent(id,true));
    }

    @PostMapping("/getSchool")
    public ResultBean getSchool(Integer id)  {
        return new ResultBean(resourceService.getAuditSchool(id,true));
    }

    @PostMapping("/getSoftware")
    public ResultBean getSoftware(Integer id, HttpSession session)  {
        return new ResultBean(resourceService.getAuditSoftware(id,true));
    }

    @PostMapping("/getTeam")
    public ResultBean getTeam(Integer id, HttpSession session)  {
        return new ResultBean(resourceService.getAuditTeam(id,true));
    }

    @PostMapping("/getTerrace")
    public ResultBean getTerrace(Integer id, HttpSession session)  {
        return new ResultBean(resourceService.getAuditTerrace(id,true));
    }

}
